package com.student.controller;

import com.student.model.Room;
import com.student.model.Student;
import com.student.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("student")
public class StudentController {
    @Autowired
    private StudentService studentService;
    //通过stuId获取学生信息
    @GetMapping("get")
    public Student getInforById (@RequestParam("id") Integer stuId){
        return studentService.getInforById(stuId);
    }
    //新增学生信息
    @PostMapping("insert")
    public int insertStudent(@RequestBody Student student){
        return studentService.insertStudent(student);
    }
    //通过Id删除学生信息
    @DeleteMapping("delete")
    public int deleteInforById (@RequestParam("id") Integer stuId){
        return studentService.deleteInforById(stuId);
    }
    //查询所有学生信息
    @GetMapping("all")
    public List<Student> getAllStudents(){
        return studentService.getAllStudents();
    }
    //修改房间信息
    @PutMapping("put")
    public int putStudentInfo(@RequestBody Student student){
        int count = studentService.putstudentInfo(student);
        return count;
    }
}
